package edu.uts.reekie.designer.implementation.figures;


import org.eclipse.draw2d.*;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;

import edu.uts.reekie.designer.figures.FixedSizeFlowLayout;

public class InfrastructureComponentFigure extends ViewComponentFigure {


	Figure main;
	Figure multiple;
	
	public InfrastructureComponentFigure() {

		setLayoutManager(new FreeformLayout());
		
		multiple = new Figure();
		multiple.setBorder(new LineBorder(ColorConstants.black));
		
		multiple.setLayoutManager(new StackLayout());
		// set up other figure properties
		multiple.setBackgroundColor(ColorConstants.white);
		multiple.setOpaque(true);
		multiple.setVisible(false);
		multiple.setLocation(new Point(5,5));
		add(multiple);
		

		// set up the layout manager
		
		main = new Panel();
		main.setBorder(new LineBorder(ColorConstants.black));
		
		main.setLayoutManager(new FixedSizeFlowLayout());
		// set up other figure properties
		main.setBackgroundColor(Colors.infrastructureBackground);
		main.setOpaque(true);
		main.setSize(DEFAULT_SIZE);
		main.setLocation(new Point(0,0));
		main.setVisible(true);
		// set up the main panel
		main.add(nameLabel);
		add(main);
		
		
	}
	
	public void setMultiple(boolean value){
		
		if (value==true){
			multiple.setVisible(true);
		} else {
			multiple.setVisible(false);
		}
		super.setMultiple(value);
	}
	
	public void setBounds(Rectangle rect) {
		super.setBounds(rect);
		
		
		if (isMultiple()){
			
			main.setSize(rect.getSize().shrink(5, 5));
			Point m = multiple.getLocation();
			multiple.setSize(rect.getSize().shrink(5, 5));
		} else {
			main.setSize(rect.getSize());
			
		}
		
		
	}
	
}
